<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
  <head>
    <base href="<%=basePath%>" />
    <title>Heat User Information Management</title>
    <script type="text/javascript">
		var path = "<%=basePath%>";
		//分摊域分摊公共参数
		var shareAreaUID = "<s:property value='shareAreaUID' />";
		var illegalIDList = "<s:property value='illegalIDList' />";
	</script>
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
	<meta http-equiv="description" content="This is my page" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>beshs/css/content.css" />
	<script type="text/javascript" src="<%=basePath%>resources/jquery/jquery-1.7.2.min.js"></script>
	<!-- 系统通用资源 -->
	<jsp:include page="/resources/resource-refer/common-resource-reference.jsp" />
	<!-- 表单校验 -->
	<jsp:include page="/resources/resource-refer/component-validform-reference.jsp" />
	<!-- 用户访问菜单路径 -->
	<jsp:include page="/resources/usertrace/common-uservisit-reference.jsp" />
  </head>
  <script type="text/javascript">
  	function submitForm() {
  		var heatRoomUID = "<s:property value='heatRoom.id' />";
  		//表单信息
  		var projectID = $("select[name='heatRoom.projectID']").val();
  		var communityID = $("select[name='heatRoom.communityID']").val();
  		var shareAreaID = $("select[name='heatRoom.shareAreaID']").val();
  		var buildingID = $("select[name='heatRoom.buildingID']").val();
  		var unitID = $("select[name='heatRoom.unitID']").val();
  		var houseNo = $("input[name='houseNo']").val();
  		var floorIndex = $("input[name='floorIndex']").val();
  		var floorPosition = $("select[name='heatRoom.floorPosition']").val();
  		var ifSideRoom = $("select[name='heatRoom.ifSideRoom']").val();
  		var roomOwner = $("input[name='roomOwner']").val();
  		var ownerTel = $("input[name='ownerTel']").val();
  		var ownerEmail = $("input[name='ownerEmail']").val();
  		var structArea = $("input[name='structArea']").val();
  		var heatArea = $("input[name='heatArea']").val();
  		var ifMeasureCharge = $("select[name='heatRoom.ifMeasureCharge']").val();
  		var reviseFactor = $("input[name='reviseFactor']").val();
  		var ifBillAutoSend = $("select[name='heatRoom.ifBillAutoSend']").val();
  		var remark = $("textarea[name='remark']").val();
  		$.getJSON(path+"beshs/heatRoomActionJson!saveOrUpdateHeatRoom.do?date="+new Date(), {
  			"heatRoom.id": heatRoomUID,
  			"heatRoom.projectID": projectID,
  			"heatRoom.communityID": communityID,
  			"heatRoom.shareAreaID": shareAreaID,
  			"heatRoom.buildingID": buildingID,
  			"heatRoom.unitID": unitID,
  			"heatRoom.houseNo": houseNo,
  			"heatRoom.floorIndex": floorIndex,
  			"heatRoom.floorPosition": floorPosition,
  			"heatRoom.ifSideRoom": ifSideRoom,
  			"heatRoom.roomOwner": roomOwner,
  			"heatRoom.ownerTel": ownerTel,
  			"heatRoom.ownerEmail": ownerEmail,
  			"heatRoom.structArea": structArea,
  			"heatRoom.heatArea": heatArea,
  			"heatRoom.ifMeasureCharge": ifMeasureCharge,
  			"heatRoom.reviseFactor": reviseFactor,
  			"heatRoom.ifBillAutoSend": ifBillAutoSend,
  			"heatRoom.remark": $.trim(remark)
  		}, function(data){
  			if(data.success) {
  				Dialog.alert("Successful Operation！", function() {
  					var index = parent.layer.getFrameIndex(window.name)
					parent.window.frames["infoVeriPage"].location = path + "beshs/shareAreaResultAction!queryAreaResultInfoListBySort.do?infoSort=heatRoom" 
							+ "&shareAreaUID=" + shareAreaUID
							+ "&illegalIDList=" + illegalIDList
							+ "&date="+ new Date();
  					parent.layer.close(index);
  				});
  			} else {
  				Dialog.alert(data.msg);
  			}
  		});
  	}
  	
  	$(function(){
		$("form[name='heatRoomForm']").Validform({
			btnSubmit: "input[name='submit']",
			btnReset: "input[name='reset']",
			tiptype: function(msg, o, cssctl){
				//msg：提示信息;
				//o:{obj:*,type:*,curform:*}, obj指向的是当前验证的表单元素（或表单对象），type指示提示的状态，值为1、2、3、4， 1：正在检测/提交数据，2：通过验证，3：验证失败，4：提示ignore状态, curform为当前form对象;
				//cssctl:内置的提示信息样式控制函数，该函数需传入两个参数：显示提示信息的对象 和 当前提示的状态（既形参o中的type）;
				if(!o.obj.is("form")){//验证表单元素时o.obj为该表单元素，全部验证通过提交表单时o.obj为该表单对象;
					var objtip=o.obj.siblings(".Validform_checktip");
					cssctl(objtip,o.type);
					objtip.text(msg);
				} else {
					var objtip=o.obj.find("#msgdemo");
					cssctl(objtip,o.type);
					objtip.text(msg);
				}
			},
			postonce: true, //开启二次提交防御，在数据成功提交后，表单将不能再继续提交
			showAllError: true, //提交表单时所有错误提示信息都会显示
			ajaxPost:true,
			beforeSubmit: function(curform) { //在验证成功后，表单提交前执行的函数，curform参数是当前表单对象
				submitForm();
				return true; //这里明确return false的话表单将不会提交
			}
		});
  	});
  </script>
  <body>
    <div class="content_all">
  		<!--导航条-->
  		<div class="insertinfo_table">
      		<form action="#" name="heatRoomForm"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      			<tr>
          			<th>Project：</th>
          			<td><s:select name="heatRoom.projectID" list="projectList" listKey="id" listValue="projectName" headerKey="" headerValue="Please select" cssClass="s_sel"
          					datatype="*" nullmsg="Please select the project！" errormsg="Please select the project！"></s:select>
            			&nbsp;<span style="color:#FF0000;">*</span>
            			<div class="Validform_checktip"></div></td>
            		<th>District：</th>
          			<td>
          				<script type="text/javascript">
	          				function reloadCommunitys(projectUID, communityUID) {
	      						$("select[name='heatRoom.communityID']").children("option").slice(1).remove();
	      						if(projectUID!=null && projectUID!="") {
	      							$.getJSON(path+"beshs/communityActionJson!queryCommunitysByBelongs.do?date="+new Date(), {
	      								projectUID: projectUID
	      							}, function(data){
	      								for(var index=0; index<data.length; index++) {
	      									if(communityUID!=null && communityUID!="" && communityUID==data[index].id) {
		        								$("select[name='heatRoom.communityID']").append("<option value='"+data[index].id+"' selected='selected'>"+data[index].communityName+"</option>");
		        							} else {
		        								$("select[name='heatRoom.communityID']").append("<option value='"+data[index].id+"'>"+data[index].communityName+"</option>");
		        							}
	      								}
	      							});
	      						}
	      					}
          				
	          				$(function() {
	      						$("select[name='heatRoom.projectID']").change(function(){
			        				var projectUID = $(this).val();
			        				var communityUID = $("select[name='heatRoom.communityID']").val();
			        				reloadCommunitys(projectUID, communityUID);
			        			});
	      					});
          				</script>
          				<s:select name="heatRoom.communityID" list="communityList" listKey="id" listValue="communityName" headerKey="" headerValue="Please select" cssClass="s_sel"
          					datatype="*" nullmsg="Please select the district！" errormsg="Please select the district！"></s:select>
            			&nbsp;<span style="color:#FF0000;">*</span>
            			<div class="Validform_checktip"></div></td>
        		</tr>
        		<tr>
          			<th>Building：</th>
          			<td>
          				<script type="text/javascript">
	          				function reloadBuildings(projectUID, communityUID, buildingUID) {
	          					$("select[name='heatRoom.buildingID']").children("option").slice(1).remove();
          						if((projectUID!=null && projectUID!="") 
          								|| (communityUID!=null && communityUID!="")) {
          							$.getJSON(path+"beshs/buildingActionJson!queryBuildingsByBelongs.do?date="+new Date(), {
          								projectUID: projectUID,
          								communityUID: communityUID
		        					}, function(data) {
		        						for(var index=0; index<data.length; index++) {
		        							if(buildingUID!=null && buildingUID!="" && buildingUID==data[index].id) {
		        								$("select[name='heatRoom.buildingID']").append("<option value='"+data[index].id+"' selected='selected'>"+data[index].buildingName+"</option>");
		        							} else {
		        								$("select[name='heatRoom.buildingID']").append("<option value='"+data[index].id+"'>"+data[index].buildingName+"</option>");
		        							}
		        						}
		        					});
          						}
	          				}
          				
	          				$(function(){
	      						$("select[name='heatRoom.projectID']").change(function(){
	      							var projectUID = $(this).val();
	      							var communityUID = $("select[name='heatRoom.communityID']").val();
	      							var buildingUID = $("select[name='heatRoom.buildingID']").val();
	      							reloadBuildings(projectUID, communityUID, buildingUID);
	      						});
	      						
								$("select[name='heatRoom.communityID']").change(function(){
									var communityUID = $(this).val();
	      							var projectUID = $("select[name='heatRoom.projectID']").val();
	      							var buildingUID = $("select[name='heatRoom.buildingID']").val();
	      							reloadBuildings(projectUID, communityUID, buildingUID);
	      						});
	      					});
          				</script>
          				<s:select name="heatRoom.buildingID" list="buildingList" listKey="id" listValue="buildingName" headerKey="" headerValue="Please select" cssClass="s_sel"
          					datatype="*" nullmsg="Please select the building！" errormsg="Please select the building！"></s:select>
            			&nbsp;<span style="color:#FF0000;">*</span>
            			<div class="Validform_checktip"></div></td>
            		<th>Shared Area：</th>
          			<td>
          				<script type="text/javascript">
	          				function reloadShareAreas(projectUID, communityUID, shareAreaUID) {
	      						$("select[name='heatRoom.shareAreaID']").children("option").slice(1).remove();
	      						if((projectUID!=null && projectUID!="") 
          								|| (communityUID!=null && communityUID!="")) {
		        					$.getJSON(path+"beshs/shareAreaActionJson!queryShareAreasByBelongings.do?date="+new Date(), {
		        						projectUID: projectUID,
		        						communityUID: communityUID
		        					}, function(data) {
		        						for(var index=0; index<data.length; index++) {
		        							if(shareAreaUID!=null && shareAreaUID!="" && shareAreaUID==data[index].id) {
		        								$("select[name='heatRoom.shareAreaID']").append("<option value='"+data[index].id+"' selected='selected'>"+data[index].areaName+"</option>");
		        							} else {
		        								$("select[name='heatRoom.shareAreaID']").append("<option value='"+data[index].id+"'>"+data[index].areaName+"</option>");
		        							}
		        						}
		        					});
		        				} 
	      					}
	      				
	          				$(function(){
	      						$("select[name='heatRoom.projectID']").change(function(){
			        				var projectUID = $(this).val();
			        				var communityUID = $("select[name='heatRoom.communityID']").val();
			        				var shareAreaUID = $("select[name='heatRoom.shareAreaID']").val();
			        				reloadShareAreas(projectUID, communityUID, shareAreaUID);
			        			});
	      						
	      						$("select[name='heatRoom.communityID']").change(function(){
									var communityUID = $(this).val();
	      							var projectUID = $("select[name='heatRoom.projectID']").val();
	      							var shareAreaUID = $("select[name='heatRoom.shareAreaID']").val();
	      							reloadShareAreas(projectUID, communityUID, shareAreaUID);
	      						});
	      					});
          				</script>
          				<s:select name="heatRoom.shareAreaID" list="shareAreaList" listKey="id" listValue="areaName" headerKey="" headerValue="Please select" cssClass="s_sel"></s:select>
            		</td>
        		</tr>
        		<tr>
        			<th>Unit：</th>
          			<td>
          				<script type="text/javascript">
          					function reloadBuildingUnits(buildingUID, unitID) {
          						$("select[name='heatRoom.unitID']").children("option").slice(1).remove();
	      						if(buildingUID!=null && buildingUID!="") {
		        					$.getJSON(path+"beshs/buildingUnitActionJson!queryBuildingUnitsByBuildingUID.do?date="+new Date(), {
		        						buildingUID: buildingUID
		        					}, function(data) {
		        						for(var index=0; index<data.length; index++) {
		        							if(unitID!=null && unitID!="" && unitID==data[index].id) {
		        								$("select[name='heatRoom.unitID']").append("<option value='"+data[index].id+"' selected='selected'>"+data[index].unitName+"</option>");
		        							} else {
		        								$("select[name='heatRoom.unitID']").append("<option value='"+data[index].id+"'>"+data[index].unitName+"</option>");
		        							}
		        						}
		        					});
		        				} 
          					}	
          				
	          				$("select[name='heatRoom.buildingID']").change(function(){
								var buildingUID = $(this).val();
	  							var unitID = $("select[name='heatRoom.unitID']").val();
	  							reloadBuildingUnits(buildingUID, unitID);
	  						});
	          				
	          				$("select[name='heatRoom.projectID']").change(function(){
	          					$("select[name='heatRoom.unitID']").children("option").slice(1).remove();
      						});
      						
							$("select[name='heatRoom.communityID']").change(function(){
								$("select[name='heatRoom.unitID']").children("option").slice(1).remove();
      						});
          				</script>
          				<s:select name="heatRoom.unitID" list="buildingUnitList" listKey="id" listValue="unitName" headerKey="" headerValue="Please select" cssClass="s_sel"
          					datatype="*" nullmsg="Please select the unit！" errormsg="Please select the unit！"></s:select>
            			&nbsp;<span style="color:#FF0000;">*</span>
            			<div class="Validform_checktip"></div></td>
            		<th>Floor：</th>
          			<td><input name="floorIndex" type="text" class="s_input" value="<s:property value='heatRoom.floorIndex' />" 
          					datatype="/^[\-0-9a-zA-Z\u4e00-\u9fa5]{1,25}$/" sucmsg="Floor Verification Passed！" nullmsg="Please enter floor！" errormsg="Floor only can be composed of letters,numbers and dashes within 1~25 characters！"/>层
            			&nbsp;<span style="color:#FF0000;">*</span>
            			<div class="Validform_checktip">Floor only can be composed of letters,numbers and dashes within 1~25 characters！</div></td>
        		</tr>
        		<tr>
        			<th>Apartment Number：</th>
          			<td><input name="houseNo" type="text" class="s_input" value="<s:property value='heatRoom.houseNo' />" 
          					datatype="/^[\-0-9a-zA-Z\u4e00-\u9fa5]{1,25}$/" sucmsg="Apartment Number Verification Passed！" nullmsg="Please enter apartment number！" errormsg="Apartment number only can be composed of letters,numbers and dashes within 1~25 characters！"/>
            			&nbsp;<span style="color:#FF0000;">*</span>
            			<div class="Validform_checktip">Apartment number only can be composed of letters,numbers and dashes within 1~25 characters！</div></td>
          			<th>Floor Location：</th>
          			<td>
          				<s:select name="heatRoom.floorPosition" list="#{'top':'Top', 'middle':'Middle', 'bottom':'Bottom'}" headerKey="" headerValue="Please select" cssClass="s_sel"></s:select>
          			</td>
        		</tr>
        		<tr>
        			<th>Building Area：</th>
          			<td><input name="structArea" type="text" class="s_input" value="<s:property value='heatRoom.structArea' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" sucmsg="Building Area Verification Passed！" nullmsg="Please enter building area！" errormsg="Please enter integral or float type value！"/>m&sup2;
          				&nbsp;<span style="color:#FF0000;">*</span>
          				<div class="Validform_checktip">Please enter integral or float type value！</div></td>
          			<th>Heating Area：</th>
          			<td><input name="heatArea" type="text" class="s_input" value="<s:property value='heatRoom.heatArea' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" sucmsg="Heating Area Verification Passed！" nullmsg="Please enter heating area！" errormsg="Please enter integral or float type value！"/>m&sup2;
          				&nbsp;<span style="color:#FF0000;">*</span>
          				<div class="Validform_checktip">Please enter integral or float type value！</div></td>
        		</tr>
        		<tr>
          			<th>Owner Name：</th>
          			<td><input name="roomOwner" type="text" class="s_input" value="<s:property value='heatRoom.roomOwner' />" /></td>
          			<th>Whether edge apartment or not：</th>
          			<td>
          				<s:select name="heatRoom.ifSideRoom" list="#{'1':'Yes', '2':'No'}" headerKey="" headerValue="Please select" cssClass="s_sel"></s:select>
          			</td>
        		</tr>
        		<tr>
          			<th>Whether Involved in Metering and Charging：</th>
          			<td>
          				<s:select name="heatRoom.ifMeasureCharge" list="#{'1':'No', '2':'Yes'}" headerKey="" headerValue="Please select" cssClass="s_sel"
          					datatype="*" nullmsg="Please select Whether Involved in Metering and Charging！" errormsg="Please select Whether Involved in Metering and Charging！"></s:select>
          				&nbsp;<span style="color:#FF0000;">*</span>
          				<div class="Validform_checktip"></div></td>
          			<th>User Correction Factor：</th>
          			<td><input name="reviseFactor" type="text" class="s_input" value="<s:property value='heatRoom.reviseFactor' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" sucmsg="User Correction Factor Verification Passed！" nullmsg="Please enter user correction factor！" errormsg="Please enter integral or float type value！"/>
          				&nbsp;<span style="color:#FF0000;">*</span>
          				<div class="Validform_checktip">Please enter integral or float type value！</div></td>
        		</tr>
        		<tr>
        			<th>Phone Number：</th>
          			<td><input name="ownerTel" type="text" class="s_input" value="<s:property value='heatRoom.ownerTel' />" 
          					datatype="/^((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)$/" ignore="ignore" errormsg="Please enter phone number in correct format！"/>
          				<div class="Validform_checktip"></div></td>
          			<th>E-mail：</th>
          			<td><input name="ownerEmail" type="text" class="s_input" value="<s:property value='heatRoom.ownerEmail' />" 
          					datatype="/^[-_A-Za-z0-9]+@([_A-Za-z0-9]+\.)+[A-Za-z0-9]{2,3}$/" ignore="ignore" errormsg="Please enter e-mail in correct format！"/>
          				<div class="Validform_checktip"></div></td>
        		</tr>
        		<tr>
          			<th>Send bill Automatically：</th>
          			<td>
          				<s:select name="heatRoom.ifBillAutoSend" list="#{'1':'Yes', '2':'No'}" headerKey="" headerValue="Please select" cssClass="s_sel"></s:select>
          			</td>
          			<th></th>
          			<td></td>
        		</tr>
        		<tr>
        			<th>Remark：</th>
          			<td colspan="3">
          				<textarea name="remark" cols="45" rows="3"
          					datatype="*1-200" ignore="ignore" errormsg="Invalid input!  please input valid content ,no more than 200pcs character"><s:property value='heatRoom.remark' /></textarea>
          				<div class="Validform_checktip"></div></td>
        		</tr>
        		<tr>
          			<td style="border:none;" colspan="4" align="center">
          				<input name="submit" type="button" value="Submit" class="s_btn" />
            			<input name="reset" type="reset" value="Reset" class="s_btn"/></td>
        		</tr>
      		</table></form>
  		</div>
	</div>
	<div class="clear"></div>
  </body>
</html>
